package uk.ac.bath.domains.misc;


public class GridFood2D extends PulseFood2D {


    //    public Vector tweaks = new Vector();
    //    public Collection getTweaks() { return tweaks;}


    int spaceX;
    int spaceY;

    public GridFood2D(int left,int size,int spacing) {
	this(left,left+size,left,left+size,spacing,spacing);
    }


    public GridFood2D(int left,int right,int top,int bot,int spaceX,int spaceY) {
	super(left,right,top,bot);
	this.spaceX=spaceX;
	this.spaceY=spaceY;

    }


//     public Object clone() {
// 	return new PulseFood2D(left_,size_);
//     }

    public void replenishFood() {
	double fLimit = foodLimit.getNumber().doubleValue();
	double fInc = foodInc.getNumber().doubleValue();


        for (int i=0 ; i < sizeY ; i += spaceY ) {
	    for (int j=0 ; j < sizeX ; j++) {
		if (food_[j][i] < 1 ) food_[j][i] = 1;
	    }
        }


        for (int i=0 ; i < sizeX ; i += spaceX ) {
	    for (int j=0 ; j < sizeY ; j++) {
		if (food_[i][j] < 1 ) food_[i][j] = 1;
	    }
	    for (int j=0 ; j < sizeY ; j += spaceY ) {
		if (food_[i][j] < fLimit ) food_[i][j] += fInc;
	    }
        }

    }

}
